﻿
using System;
using System.Collections.Generic;

namespace HttpClient
{
	public class HeaderConfiguration<T>
		where T : class
	{
		T src;
		HttpRequest request;
		
		public HeaderConfiguration(HttpRequest request, T src)
		{
			this.src = src;
			this.request = request;
        }

        public HeaderConfiguration<T> Parameter(String name, String value)
        {
            request.urlParameters.Add(name, value);
            return this;
        }

        public HeaderConfiguration<T> Parameters(Dictionary<String, String> parameters)
        {
            foreach (var parameter in parameters)
            {
                Parameter(parameter.Key, parameter.Value);
            }
            return this;
        }
		
		public HeaderConfiguration<T> Header(String name, String value)
		{
			request.headers.Add(name, value);
			return this;
		}
			
		public HeaderConfiguration<T> Credential(String userName, String password)
		{
			request.userName = userName;
			request.password = password;
			return this;
		}
			
		public HeaderConfiguration<T> AllowAutoRedirect(bool allowAutoRedirect)
		{
			request.allowAutoRedirect = allowAutoRedirect;
			return this;
		}
		
		
		
		public T And { get { return src; } }
	}
}
